package com.lm.easy.example;

import org.jeasy.rules.api.*;
import org.jeasy.rules.core.DefaultRulesEngine;
import org.jeasy.rules.mvel.MVELRule;

public class ExpressionRuleExample {
    public static void main(String[] args) {
        Facts facts = new Facts();
        facts.put("age", 16);

        Rule rule = new MVELRule()
                .name("AgeRule")
                .description("Check age with expression")
                .when("age >= 18")
                .then("System.out.println(\"用户已成年，可以进入系统 ✅\");");

        Rules rules = new Rules();
        rules.register(rule);

        RulesEngine engine = new DefaultRulesEngine();
        engine.fire(rules, facts);
    }
}